//
//  RLNearbyFlowLayout.m
//  RelaxLinkProduct
//
//  Created by relax on 2017/11/29.
//  Copyright © 2017年 relax. All rights reserved.
//

#import "RLNearbyFlowLayout.h"

/** 每个 item 的行列间距 */
#define lineAndColunmMargin 10
/** 一行 4 个 item */
#define lineItemCount 3

@implementation RLNearbyFlowLayout

- (void)prepareLayout {
    [super prepareLayout];
    
    // 设置每个item 的宽高
    /** 一行4个 */
    CGFloat w = (SCREEN_WIDTH - (lineAndColunmMargin * (lineItemCount + 1))) / lineItemCount;
    CGFloat h = w;
    self.itemSize = CGSizeMake(w, h);
    self.sectionInset = UIEdgeInsetsMake(lineAndColunmMargin, lineAndColunmMargin, lineAndColunmMargin, lineAndColunmMargin);
    
    self.minimumLineSpacing = lineAndColunmMargin;
    self.minimumInteritemSpacing = lineAndColunmMargin;
    
    self.collectionView.showsVerticalScrollIndicator = NO;
    self.collectionView.showsHorizontalScrollIndicator = NO;
    
    self.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    self.collectionView.alwaysBounceVertical = YES;
}

@end
